-
-
Notifications
You must be signed in to change notification settings - Fork 443
Improve update logic & Fix update logic issue & Add Input for Query #3502
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR improves the update logic in the main view model by refactoring how running and current queries are tracked and by updating the QueryBuilder.Build method signature to accept separate input and trimmed text parameters.
- Refactored MainViewModel to replace _isQueryRunning with two distinct query state variables.
- Updated QueryBuilder.Build calls in view model, tests, and main window to pass both raw and trimmed query text.
- Added documentation for the new Query.Input property and corresponding changes in QueryBuilder.
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
Flow.Launcher/ViewModel/MainViewModel.cs | Refactored query state tracking and updated QueryBuilder.Build invocations. |
Flow.Launcher/MainWindow.xaml.cs | Updated QueryBuilder.Build call for consistency in query text handling. |
Flow.Launcher.Test/QueryBuilderTest.cs | Adjusted tests to accommodate the updated QueryBuilder.Build signature. |
Flow.Launcher.Plugin/Query.cs | Added Input property documentation. |
Flow.Launcher.Core/Plugin/QueryBuilder.cs | Changed Build method signature to accept both raw input and trimmed text. |
Comments suppressed due to low confidence (1)
Flow.Launcher/ViewModel/MainViewModel.cs:372
- [nitpick] Ensure that passing the untrimmed QueryText as the first parameter while the second parameter is trimmed is the intended behavior, and document this design choice for clarity.
var query = QueryBuilder.Build(QueryText, QueryText.Trim(), PluginManager.NonGlobalPlugins);
This comment has been minimized.
This comment has been minimized.
Be a legend 🏆 by adding a before and after screenshot of the changes you made, especially if they are around UI/UX. |
This comment has been minimized.
This comment has been minimized.
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. 📝 WalkthroughWalkthroughAdds an untrimmed input field to Query ( Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant User
participant MainWindow
participant MainViewModel
participant QueryBuilder
participant Plugins
User->>MainWindow: types rawInput
MainWindow->>MainViewModel: Submit QueryText (rawInput)
MainViewModel->>QueryBuilder: Build(rawInput, processedText, plugins)
Note right of QueryBuilder #DDDDFF: sets Query.Input = rawInput
QueryBuilder-->>MainViewModel: Query { Input, Search, RawQuery, ... }
MainViewModel->>MainViewModel: set _progressQuery and _updateQuery
MainViewModel->>Plugins: run plugin queries (async, cancellable)
alt query still current
MainViewModel->>MainWindow: show progress, update results
else cancelled or replaced
MainViewModel->>MainWindow: clear/hide results
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (2)
Flow.Launcher/ViewModel/MainViewModel.cs (2)
239-265
: Redundant guards – can be collapsed for clarityThe same three-part condition (
_currentQuery == null || e.Query.RawQuery != _currentQuery.RawQuery || …
) is evaluated twice, once before cloning the results and once after.
Keeping a single guard at the top of the handler avoids duplication and a tiny amount of wasted work.- if (_currentQuery == null || e.Query.RawQuery != _currentQuery.RawQuery || e.Token.IsCancellationRequested) - { - return; - } - - var token = e.Token == default ? _updateSource.Token : e.Token; - … - if (_currentQuery == null || e.Query.RawQuery != _currentQuery.RawQuery || token.IsCancellationRequested) - { - return; - } + var token = e.Token == default ? _updateSource.Token : e.Token; + if (_currentQuery == null || + e.Query.RawQuery != _currentQuery.RawQuery || + token.IsCancellationRequested) + { + return; + }
372-373
: Minor readability nit – avoid double-trim
QueryText
is already passed as the raw input. CallingQueryText.Trim()
for the second parameter means the string is trimmed twice insideBuild
. You can save an allocation by trimming once:-var query = QueryBuilder.Build(QueryText, QueryText.Trim(), PluginManager.NonGlobalPlugins); +var trimmed = QueryText.Trim(); +var query = QueryBuilder.Build(QueryText, trimmed, PluginManager.NonGlobalPlugins);
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
Flow.Launcher.Core/Plugin/QueryBuilder.cs
(3 hunks)Flow.Launcher.Plugin/Query.cs
(1 hunks)Flow.Launcher.Test/QueryBuilderTest.cs
(3 hunks)Flow.Launcher/MainWindow.xaml.cs
(1 hunks)Flow.Launcher/ViewModel/MainViewModel.cs
(9 hunks)
🧰 Additional context used
🧠 Learnings (1)
Flow.Launcher/ViewModel/MainViewModel.cs (1)
Learnt from: Yusyuriv
PR: Flow-Launcher/Flow.Launcher#3118
File: Flow.Launcher/ViewModel/MainViewModel.cs:1404-1413
Timestamp: 2024-12-08T21:12:12.060Z
Learning: In the `MainViewModel` class, the `_lastQuery` field is initialized in the constructor and is never null.
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: gitStream.cm
- GitHub Check: gitStream.cm
- GitHub Check: build
🔇 Additional comments (11)
Flow.Launcher.Plugin/Query.cs (1)
10-14
: Good addition of theInput
property with clear documentationThe new
Input
property with appropriate XML documentation clearly explains its purpose and usage guidance. The warning about usingSearch
property instead is consistent with the documentation forRawQuery
.Flow.Launcher/MainWindow.xaml.cs (1)
411-411
: UpdatedQueryBuilder.Build
call with proper parametersThe call has been correctly updated to pass both the raw query text and the trimmed text as separate parameters, aligning with the updated method signature in
QueryBuilder.cs
.Flow.Launcher.Test/QueryBuilderTest.cs (3)
19-19
: Test adjusted to use updatedQueryBuilder.Build
signatureThe test call has been properly updated to include the raw input parameter, maintaining test integrity while accommodating the API change.
42-42
: Test adjusted to use updatedQueryBuilder.Build
signatureThe test call has been properly updated to include the raw input parameter, maintaining test integrity while accommodating the API change.
54-54
: Test adjusted to use updatedQueryBuilder.Build
signatureThe test call has been properly updated to include the raw input parameter, maintaining test integrity while accommodating the API change.
Flow.Launcher.Core/Plugin/QueryBuilder.cs (4)
9-9
: Method signature updated to include the raw input parameterThe
Build
method signature has been enhanced to accept the raw input as a separate parameter, which will be used to populate the newInput
property on theQuery
class.
14-15
: Minor formatting changeSmall formatting adjustment with no functional impact.
25-26
: Additional whitespace added for readabilitySmall formatting improvement to enhance code readability.
Also applies to: 32-33
42-42
: Correctly setting the newInput
propertyThe new
Input
property is properly populated with the raw input parameter, completing the implementation of this feature.Flow.Launcher/ViewModel/MainViewModel.cs (2)
1274-1281
: Potential visibility race on_runningQuery
_runningQuery
is written on the UI thread and later read from aTask.Delay
continuation running on a ThreadPool thread.
Although reference assignments are atomic, withoutvolatile
/Interlocked
there is no publish-happens-before relation; the ThreadPool may observe a stale value.If correctness depends on the most recent write, consider:
private volatile Query _runningQuery;or guarding access with a lock/
Interlocked.Exchange
.Would you verify if stale reads could surface in practice? If so, I can help prepare a patch.
1396-1397
: Verify parameter order matchesQueryBuilder.Build
signatureJust a sanity check:
Build(rawInput, processedText, nonGlobalPlugins)
is expected.
Confirm thatQueryText
(raw) andqueryBuilder.ToString().Trim()
(processed) are in the correct order to ensureQuery.Input
holds the unmodified user text.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
♻️ Duplicate comments (2)
Flow.Launcher/ViewModel/MainViewModel.cs (2)
35-36
: Improved state tracking with dedicated Query objectsThis is a good improvement over using a boolean flag. Tracking queries as objects allows for more precise state management and validation.
The existing suggestion to rename these variables to
_progressQuery
and_updateQuery
to more clearly indicate their purposes is still valid.
1254-1255
:⚠️ Potential issueCompile-time error:
TaskScheduler
is not awaitable
await TaskScheduler.Default;
will not compile becauseTaskScheduler
does not implementGetAwaiter()
.-// Switch to ThreadPool thread -await TaskScheduler.Default; +// Switch to ThreadPool thread +await Task.Yield(); // or `await Task.Run(() => {}, _updateSource.Token);`
🧹 Nitpick comments (1)
Flow.Launcher/ViewModel/MainViewModel.cs (1)
260-263
: Redundant validation checkThis is a duplicate of the check on line 240. While it's valid to verify conditions haven't changed, consider extracting this validation to a helper method to avoid duplication.
-if (_updateQuery == null || e.Query.RawQuery != _updateQuery.RawQuery || token.IsCancellationRequested) -{ - return; -} +if (IsQueryMismatchOrCancelled(_updateQuery, e.Query, token)) +{ + return; +} // Add this helper method to the class +private bool IsQueryMismatchOrCancelled(Query currentQuery, Query eventQuery, CancellationToken token) +{ + return currentQuery == null || eventQuery.RawQuery != currentQuery.RawQuery || token.IsCancellationRequested; +}
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
Flow.Launcher/ViewModel/MainViewModel.cs
(9 hunks)
🧰 Additional context used
🧠 Learnings (1)
Flow.Launcher/ViewModel/MainViewModel.cs (1)
Learnt from: Yusyuriv
PR: Flow-Launcher/Flow.Launcher#3118
File: Flow.Launcher/ViewModel/MainViewModel.cs:1404-1413
Timestamp: 2024-12-08T21:12:12.060Z
Learning: In the `MainViewModel` class, the `_lastQuery` field is initialized in the constructor and is never null.
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: gitStream workflow automation
- GitHub Check: gitStream.cm
- GitHub Check: build
🔇 Additional comments (9)
Flow.Launcher/ViewModel/MainViewModel.cs (9)
240-240
: Fixed update logic comparisonThis fixes the core issue where the update logic incorrectly compared
e.Query.RawQuery
withQueryText
instead of comparing equivalent objects.
373-373
: Updated QueryBuilder.Build call with Input parameterCorrectly updated to pass both raw input and trimmed text to match the updated signature.
1221-1221
: Reset query state before processingGood practice to initialize the query state before starting a new query process.
1241-1246
: Early return optimization for changed queriesThis is a good optimization to prevent processing outdated queries when user input changes rapidly.
1251-1252
: Improved query state trackingSetting both the progress and update query objects provides better tracking of the query lifecycle.
1291-1302
: Progress bar visibility linked to query stateGood implementation of delayed progress bar visibility that also checks if the query is still active before showing it.
1325-1332
: Reset progress query after completionProperly manages the progress state and progress bar visibility after query execution completes.
1334-1338
: Added safety with try-finally blockThe finally block ensures the query state is cleaned up even if an exception occurs, preventing state leakage.
1414-1414
: Updated call to match new QueryBuilder.Build signatureCorrectly updated to provide both the original input and the processed query string.
Until we can actually figure out what's causing it. |
This comment has been minimized.
This comment has been minimized.
🥷 Code experts: theClueless Jack251970 has most 👩💻 activity in the files. See details
Activity based on git-commit:
Knowledge based on git-blame:
Activity based on git-commit:
Knowledge based on git-blame:
Activity based on git-commit:
Knowledge based on git-blame:
Activity based on git-commit:
Knowledge based on git-blame:
Activity based on git-commit:
Knowledge based on git-blame: To learn more about /:\ gitStream - Visit our Docs |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (3)
Flow.Launcher/ViewModel/MainViewModel.cs (3)
286-293
: Use the resolved cancellation token in the early guard to avoid wasted work.If
e.Token
is default, the current guard won’t respect_updateToken
until later, after cloning results.Apply:
- if (_updateQuery == null || e.Query.Input != _updateQuery.Input || e.Token.IsCancellationRequested) - { - return; - } - - var token = e.Token == default ? _updateToken : e.Token; + var token = e.Token == default ? _updateToken : e.Token; + if (_updateQuery == null || e.Query.Input != _updateQuery.Input || token.IsCancellationRequested) + { + return; + }
441-445
: SnapshotQueryText
to avoid a tiny race during Backspace.Take a local copy before Build; prevents edge cases while typing.
- var query = QueryBuilder.Build(QueryText, QueryText.Trim(), PluginManager.NonGlobalPlugins); + var input = QueryText; + var query = QueryBuilder.Build(input, input.Trim(), PluginManager.NonGlobalPlugins);
1393-1420
: UI-bound property updates from background threads.After switching to the thread pool, several bindings are set off-UI-thread (PluginIconPath/Source, SearchIconVisibility, ProgressBarVisibility). This risks cross-thread access issues in WPF.
- Verify no cross-thread exceptions occur; otherwise marshal these sets to the UI dispatcher.
Example for the progress bar continuation:
- _ = Task.Delay(200, currentCancellationToken).ContinueWith(_ => - { - if (_progressQuery != null && _progressQuery.Input == query.Input) - { - ProgressBarVisibility = Visibility.Visible; - } - }, + _ = Task.Delay(200, currentCancellationToken).ContinueWith(_ => + { + if (_progressQuery != null && _progressQuery.Input == query.Input) + { + Application.Current?.Dispatcher.Invoke(() => { + ProgressBarVisibility = Visibility.Visible; + }); + } + }, currentCancellationToken, TaskContinuationOptions.NotOnCanceled, TaskScheduler.Default);Apply same pattern (or refactor to a helper) for other UI property sets performed after the thread-pool switch.
Also applies to: 1433-1444, 1491-1499
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
Flow.Launcher/ViewModel/MainViewModel.cs
(9 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2024-12-08T21:12:12.060Z
Learnt from: Yusyuriv
PR: Flow-Launcher/Flow.Launcher#3118
File: Flow.Launcher/ViewModel/MainViewModel.cs:1404-1413
Timestamp: 2024-12-08T21:12:12.060Z
Learning: In the `MainViewModel` class, the `_lastQuery` field is initialized in the constructor and is never null.
Applied to files:
Flow.Launcher/ViewModel/MainViewModel.cs
🧬 Code graph analysis (1)
Flow.Launcher/ViewModel/MainViewModel.cs (3)
Flow.Launcher.Core/Plugin/QueryBuilder.cs (2)
Query
(9-62)QueryBuilder
(7-63)Flow.Launcher.Plugin/Query.cs (2)
Query
(8-113)ToString
(112-112)Flow.Launcher.Core/Plugin/PluginManager.cs (5)
PluginManager
(24-829)PluginManager
(166-172)ICollection
(313-336)ICollection
(338-341)PluginPair
(467-470)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: build
🔇 Additional comments (7)
Flow.Launcher/ViewModel/MainViewModel.cs (7)
39-41
: Clarify_progressQuery
vs_updateQuery
roles (naming or doc).These track similar-but-different states; consider clearer names or brief XML comments to prevent confusion during maintenance.
1368-1369
: Good guard withQuery.Input
vsQueryText
.Prevents stale work when input changes mid-flight.
1450-1456
: Nice: proactively clear results when no update tasks (home).Prevents stale items and aligns with the new non-query clearing logic.
1603-1604
: Build with empty input/text for whitespace case is correct.
1623-1624
: Good fix: pass method parameter as Input to avoid race.Matches the new signature and prevents stale-query mismatches.
1936-1939
: No change required — projects target .NET 9 so CancelAsync is supported. All csproj TargetFrameworks are net9.0(-windows...), and CancelAsync was introduced in .NET 8, so the CancelAsync calls will compile.
1384-1386
: No change required —await TaskScheduler.Default
is valid (VS Threading present transitively)MainViewModel.cs has
using Microsoft.VisualStudio.Threading
and Flow.Launcher references Flow.Launcher.Infrastructure which contains<PackageReference Include="Microsoft.VisualStudio.Threading" Version="17.14.15" />
, so the awaitable extension is available.
@jjw24 I failed to reproduce this issue during today's usage and fast typing. But since the first issue you pointed out is related to https://ci.appveyor.com/project/JohnTheGr8/flow-launcher/builds/52791393/artifacts |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
Flow.Launcher/MainWindow.xaml.cs
(1 hunks)Flow.Launcher/ViewModel/MainViewModel.cs
(9 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- Flow.Launcher/MainWindow.xaml.cs
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2024-12-08T21:12:12.060Z
Learnt from: Yusyuriv
PR: Flow-Launcher/Flow.Launcher#3118
File: Flow.Launcher/ViewModel/MainViewModel.cs:1404-1413
Timestamp: 2024-12-08T21:12:12.060Z
Learning: In the `MainViewModel` class, the `_lastQuery` field is initialized in the constructor and is never null.
Applied to files:
Flow.Launcher/ViewModel/MainViewModel.cs
🧬 Code graph analysis (1)
Flow.Launcher/ViewModel/MainViewModel.cs (3)
Flow.Launcher.Core/Plugin/QueryBuilder.cs (2)
Query
(9-62)QueryBuilder
(7-63)Flow.Launcher.Plugin/Query.cs (2)
Query
(8-113)ToString
(112-112)Flow.Launcher.Core/Plugin/PluginManager.cs (5)
PluginManager
(23-821)PluginManager
(161-167)ICollection
(305-328)ICollection
(330-333)PluginPair
(459-462)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: build
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (6)
Flow.Launcher/ViewModel/MainViewModel.cs (6)
39-40
: Naming and intent are clear; keep.The split between progress tracking and update gating reads well. Consider brief XML docs to cement intent for future maintainers.
286-293
: Harden ResultsUpdated gating and avoid mixed-token checks.Use the resolved token for both the cancellation check and keep comparisons ordinal for perf/correctness on raw text.
- if (_updateQuery == null || e.Query.Input != _updateQuery.Input || e.Token.IsCancellationRequested) + var token = e.Token == default ? _updateToken : e.Token; + if (token.IsCancellationRequested + || _updateQuery == null + || !string.Equals(e.Query.Input, _updateQuery.Input, StringComparison.Ordinal)) { return; } - - var token = e.Token == default ? _updateToken : e.Token;
1417-1436
: Progress-bar trigger: compare with ordinal and consider snapshot.Use ordinal comparison for raw text; if you adopt the input snapshot above, compare against it for extra safety.
- if (_progressQuery != null && _progressQuery.Input == query.Input) + if (_progressQuery != null && + string.Equals(_progressQuery.Input, query.Input, StringComparison.Ordinal)) { ProgressBarVisibility = Visibility.Visible; }
1687-1702
: Minor:_lastQuery
is never null in ctor; simplify null-propagation.You can drop the null-conditional on
_lastQuery
for a tiny clarity bump. Not a blocker.Based on learnings
- if (_lastQuery?.ActionKeyword != query?.ActionKeyword) + if (_lastQuery.ActionKeyword != query?.ActionKeyword)
1350-1415
: Potential cross-thread property updates (minor).Property assignments (e.g., PluginIconPath, SearchIconVisibility) happen after the thread hop in the current code. With the compile fix above (use Task.Yield), you’ll continue on the UI context and avoid cross-thread UI-binding surprises.
286-323
: Use ordinal comparisons consistently for raw text.All string-equality checks on Input/RawQuery should be
StringComparison.Ordinal
.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
Flow.Launcher/ViewModel/MainViewModel.cs
(8 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2024-12-08T21:12:12.060Z
Learnt from: Yusyuriv
PR: Flow-Launcher/Flow.Launcher#3118
File: Flow.Launcher/ViewModel/MainViewModel.cs:1404-1413
Timestamp: 2024-12-08T21:12:12.060Z
Learning: In the `MainViewModel` class, the `_lastQuery` field is initialized in the constructor and is never null.
Applied to files:
Flow.Launcher/ViewModel/MainViewModel.cs
🧬 Code graph analysis (1)
Flow.Launcher/ViewModel/MainViewModel.cs (3)
Flow.Launcher.Core/Plugin/QueryBuilder.cs (2)
Query
(9-62)QueryBuilder
(7-63)Flow.Launcher.Plugin/Query.cs (2)
Query
(8-113)ToString
(112-112)Flow.Launcher.Core/Plugin/PluginManager.cs (3)
PluginManager
(23-821)PluginManager
(161-167)PluginPair
(459-462)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: gitStream.cm
🔇 Additional comments (14)
Flow.Launcher/ViewModel/MainViewModel.cs (14)
444-452
: Correct: Build now receives both Input (untrimmed) and text (trimmed).This aligns Backspace with the new QueryBuilder API and preserves user input semantics.
1337-1345
: Don’t abort after shortcut expansion (stale guard).ConstructQueryAsync can rewrite QueryText (builtin/custom shortcuts). Comparing
query.Input
with the liveQueryText
right after that will often differ and prematurely return, yielding an empty/stale result pane after expansions.Apply this to snapshot the input before constructing the query and relax the guard to allow either the original input or the expanded RawQuery:
- var query = await ConstructQueryAsync(QueryText, Settings.CustomShortcuts, Settings.BuiltinShortcuts); + var inputSnapshot = QueryText; + var query = await ConstructQueryAsync(inputSnapshot, Settings.CustomShortcuts, Settings.BuiltinShortcuts); @@ - // Check if the input text matches the query text - if (query.Input != QueryText) return; + // Short-circuit only if user has typed something new unrelated to this query + var currentText = QueryText; + if (!string.Equals(currentText, inputSnapshot, StringComparison.Ordinal) && + !string.Equals(currentText, query.RawQuery, StringComparison.Ordinal)) + { + return; + }
1485-1499
: Result-clearing logic looks correct; good early return when no update tasks.This prevents stale results when home-page plugins are all disabled or absent.
If you want to be extra sure, test with:
- ShowHistoryResultsForHomePage = false
- All home plugins disabled
- Enter/clear text to confirm the view clears.
1596-1599
: Good: Build for whitespace path sets both Input and RawQuery empty.This keeps IsHomeQuery true and avoids null queries.
1618-1619
: Good: pass the method parameter as Input to avoid races.Using
queryText
here ensures the built Query carries the exact input used for construction.
217-277
: Channel consumer resiliency looks fine; continuation restarts on fault.No action needed.
571-588
: UI navigation helpers unchanged; LGTM.Selection and preview update wiring remains consistent.
Also applies to: 607-622
1510-1517
: ClearResults helper is cohesive and idempotent.Approach to collapse/clear/reset states is sound.
1523-1572
: Per-plugin query path is correct; good use of Task.Yield and cloning.No issues spotted.
327-338
: Clock/date timer ok.PeriodicTimer loop is simple and cancellation-free as intended.
1951-1958
: Dialog focus restore is guarded and logged; ok.No changes requested.
2276-2303
: Dispose pattern correct; writers completed and tasks disposed.Looks good.
1379-1381
: Compile-time error:TaskScheduler
is not awaitable.
await TaskScheduler.Default;
won’t compile and also risks property updates off the UI thread. Use an awaitable construct; you don’t need to hop threads here since plugin work is already offloaded per-plugin.- // Switch to ThreadPool thread - await TaskScheduler.Default; + // Yield once without changing context (plugin queries run on background tasks) + await Task.Yield();
1335-1499
: No extraawait TaskScheduler.Default
or stale-query guards found
Only the await at MainViewModel.cs:1380 and the input guard at 1363 exist.
This comment has been minimized.
This comment has been minimized.
7e1c441
to
5f10e02
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@check-spelling-bot Report🔴 Please reviewSee the 📂 files view, the 📜action log, or 📝 job summary for details.
See ❌ Event descriptions for more information. Forbidden patterns 🙅 (1)In order to address this, you could change the content to not match the forbidden patterns (comments before forbidden patterns may help explain why they're forbidden), add patterns for acceptable instances, or adjust the forbidden patterns themselves. These forbidden patterns matched content: s.b. workaround(s)
If the flagged items are 🤯 false positivesIf items relate to a ...
|
From #3314. Resolve #2605.
Improve update logic
Improve main view model update logic.
Fix update logic issue
We should not use
e.Query.RawQuery != QueryText
becauseQueryText
(Input) is different fromRawQuery
(Query).Add new property Input for Query
Input
is the property without trimming whitespace and it can help developer get the raw input.Clear results when there are no update tasks
In this function, we need to reset all things because there are no update tasks.
Test